const enterpriseVue = new Vue({
  el: '#app',
  data() {
    return {
      pickerOptions: pickerOptions,
      rules: {
        name: [{
          required: true,
          message: '请输入栏目名称',
          trigger: 'blur',
        }],
        // src: [{
        //   required: true,
        //   message: '请输入图片地址',
        //   trigger: 'blur',
        // }],
        // url: [{
        //   required: true,
        //   message: '请输入链接地址',
        //   trigger: 'blur',
        // }],
        // zone: [{
        //   required: true,
        //   message: '请选择所属区域',
        //   trigger: 'change'
        // }]
      },
      dialogVisible: false,
      form: {
        Data: "column_main",
        page: 1,			//页数
        limit: 10,			//每页数据条数
        Enterprise_Info_SerialNumber: $.cookie("enterprise"),//状态
        Activity: "0"
      },
      loading: false,
      form2: {}
    }
  },
  mounted() {
    const Column_Id = sessionStorage.getItem("Column_Id")
    this.getList(Column_Id)
  },
  methods: {
    getList(Column_Id) {     //换页方法
      let _this = this
      this.form.Primary_Key = Column_Id;
      this.form.Primary_Key_Name = "Column_Id";
      this.form.page = 1;
      this.form.limit = 10;
      $.ajax({
        type: 'POST',
        //	url: "../getContractListByConditionAction",
        url: DomainName + '/getTableInquiryAction?token=' + $.cookie("token"),
        data: this.form,
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        success: function (Result) {
          console.log(Result);
          _this.form2 = Result.tableData[0];      //将获取的数据存到表格数据中
          // _this.total = parseInt(Result.limit);
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      });
    },
    submitForm() {
      this.loading = true;
      this.modify(this.form2)
    },
    modify(form) {
      const _this = this;
      let data = {
        Data: JSON.stringify({
          Modify: {
            column_main: [form]
          }
        })
      };
      $.ajax({
        url: DomainName + '/getEditAction?token=' + $.cookie('token'),
        type: 'POST',
        data,
        error: function (array) {
          console.log(array);
          _this.$message.error("修改失败，请稍后再试")
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        success: function (res) {
          if (res.Status == 'success') {
            _this.$message({
              type: 'success',
              message: '修改成功!'
            });
            window.history.go(-1);
            // _this.getList(_this.form)
          }
        }
      })
    },
    deal() {
      const modify = deepClone(this.form)
      return { add: null, modify };
    },
  }
})